#include "stdafx.h"
#include "GZIP.h"



int CGZIP::UnCompressGzip(string & str, ULONG & gzLen)
{
	if (str.empty())return Z_ERRNO;
	uLong zipDataLen = str.length();
	gzLen = zipDataLen * 18;

	char *gzData = new char[gzLen];
	memset(gzData, 0, gzLen);
	int iResult = CZIP::UnZip(str, gzData, &gzLen);
	if (iResult == Z_OK)
	{
		str = gzData;
	}

	delete[]gzData;

	return iResult;
}

bool CGZIP::Process(string & strEntityBody)
{
	uLong iEntityBodyLength = strEntityBody.length();

	if (UnCompressGzip(strEntityBody, iEntityBodyLength) == Z_OK)
	{
		return true;
	}
	else
		return false;
}
